<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="">
    <textarea id="content" rows="5" cols="50"></textarea><br />
    <input type="submit" value="Send" id="send">
</form>

<script src="http://mat1.gtimg.com/libs/jquery2/2.1.2/jquery2.min.js"></script>
<script>
    $(function () {
        if ("WebSocket" in window)
        {
            // 打开一个 web socket
            var ws = new WebSocket("ws://172.17.0.2:9502/echo");


        }
        else
        {
            // 浏览器不支持 WebSocket
            alert("you brower is unable WebSocket!");
        }


        $('#send').click(function () {
            var content = $("#content").val();
            ws.send(content);
        });
    })
</script>
</body>
</html>